package jlibrarian.entities;

import java.util.Calendar;

/**
 * Created by IntelliJ IDEA.
 * User: MantaEx
 * Date: 23.2.11
 * Time: 18:42
 * To change this template use File | Settings | File Templates.
 */
public class Rent
{
    private int rid;
    private Customer customer;
    private Book book;

    private Calendar borrowed;
    private Calendar toReturn;
    private Calendar returned;

    /**
     * Creates a new rent.
     */
    public Rent(){
    }

    /**
     * Creates a new rent.
     *
     * @param customer  Customer who is borrowing the books.
     * @param book     Books the user is borrowing.
     * @param borrowed  Time of the rent.
     * @param toReturn  Where the books must be returned.
     */
    public Rent(Customer customer, Book book, Calendar borrowed, Calendar toReturn)
    {
        this.customer = customer;
        this.book = book;
        this.borrowed = borrowed;
        this.toReturn = toReturn;
    }

    public Book getBook() {
        return book;
    }

    public void setBook(Book book) {
        this.book = book;
    }

    public Calendar getBorrowed() {
        return borrowed;
    }

    public void setBorrowed(Calendar borrowed) {
        this.borrowed = borrowed;
    }

    public Customer getCustomer() {
        return customer;
    }

    public void setCustomer(Customer customer) {
        this.customer = customer;
    }

    public Calendar getReturned() {
        return returned;
    }

    public void setReturned(Calendar returned) {
        this.returned = returned;
    }

    public Calendar getToReturn() {
        return toReturn;
    }

    public void setToReturn(Calendar toReturn) {
        this.toReturn = toReturn;
    }

    public int getRid() {
        return rid;
    }

    public void setRid(int rid) {
        this.rid = rid;
    }
    
    @Override
    public boolean equals(Object o)
    {
        if(o == null)
            return false;
        
        if(!(o instanceof Rent))
            return false;
    
        Rent r = (Rent) o;
        
        if(r.getRid() != this.getRid())
            return false;
       
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 59 * hash + this.rid;
        return hash;
    }
}
